﻿
namespace N_dimenslArr
{
    using System;
    using System.Collections.Generic;
    using System.Diagnostics;
    using System.Linq;
    using System.Text;
    using Tao.FreeGlut;
    using Tao.OpenGl;
    using Tao.Platform;
    
    public class GeoLink
    {
        public const double shift = 0.004;
        
        public GeoLink()
        {
            this.From = new double[] { 0, 0 };
            this.To = new double[] { 1, 1 };
        }

        public GeoLink(double[] from, double[] to)
        {
            Debug.Assert(from.Length > 0, "from.Length > 0");
            Debug.Assert(to.Length > 0, "to.Length > 0");
            this.From = from;
            this.To = to;
            this.Status = false;
        }

        public double[] From { get; set; }

        public double[] To { get; set; }
        
        public bool Status { get; set; }

        public uint FromId { get; set; }

        public uint ToId { get; set; }

        public virtual void Render(double zoom)
        {
            //double shift = ;
            
            Gl.glPushAttrib(Gl.GL_COLOR);
            Gl.glPushAttrib(Gl.GL_LINE_BIT);
            
            Gl.glLineWidth(5);
            if (this.Status)
            {
                Gl.glColor4f(1.0f, 0, 0, 0.4f);
            }
            else
            {
              Gl.glColor4f(0, 1.0f, 0, 0.4f);
            }
            
            Gl.glBegin(Gl.GL_LINES);
            
            Gl.glVertex3d(this.From[0], this.From[1], 0);
            Gl.glVertex3d(this.To[0], this.To[1], 0);
            
            Gl.glLineWidth(3);
            Gl.glColor4f(0, 1.0f, 0, 0.3f);

            Gl.glVertex3d(this.From[0], this.From[1], 0);
            Gl.glVertex3d(this.To[0], this.To[1], 0);
            Gl.glColor4f(0, 1.0f, 0, 0.25f);
             
            Gl.glVertex3d(this.From[0], this.From[1] + shift, 0);
            Gl.glVertex3d(this.To[0], this.To[1] + shift, 0);

            Gl.glVertex3d(this.From[0] + shift, this.From[1], 0);
            Gl.glVertex3d(this.To[0] + shift, this.To[1], 0);
 
             Gl.glVertex3d(this.From[0] - shift, this.From[1], 0);
             Gl.glVertex3d(this.To[0] - shift, this.To[1], 0);
             
            Gl.glVertex3d(this.From[0], this.From[1] - shift, 0);
             Gl.glVertex3d(this.To[0], this.To[1] - shift, 0);

            Gl.glEnd();

            Gl.glPopAttrib();
            Gl.glPopAttrib();
        }
    }
}
